package cn.sheep.dmp.tags

import org.apache.commons.lang3.StringUtils
import org.apache.spark.sql.Row

/**
  * sheep.Old @ 64341393
  * Created 2018/4/1
  */
object Tags4Ads extends Tags {

    override def makeTags(args: Any*): Map[String, Int] = {

        var map = Map[String, Int]()
        val row = args(0).asInstanceOf[Row]

        // 逻辑
        val adSpt = row.getAs[Int]("adspacetype")
        if (adSpt > 0 && adSpt < 10) map += (("LC0" + adSpt, 1)) else map += "LC" + adSpt -> 1
        val adSptn = row.getAs[String]("adspacetypename")
        if (StringUtils.isNotEmpty(adSptn)) map += "LN" + adSptn -> 1


        // 渠道
        val channelId = row.getAs[Int]("adplatformproviderid")
        if (channelId > 0) map += "CN" + channelId -> 1

        map
    }
}
